const express = require('express');
const bodyParser = require('body-parser');

const app = express();
const port = 3000;

// 使用 body-parser 中间件
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// 示例接口
app.get('/api/test', (req, res) => {
  res.json({ message: 'This is a test response' });
});

app.post('/api/test', (req, res) => {
  res.json({ data: req.body, message: 'Received POST request' });
});

app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});